package JiHeDemo.mygenneric;

import JiHeDemo.Student;

import java.util.HashSet;
import java.util.Iterator;

/**
 * @author 86150
 */
public class Set1 {
	public static void a(String[] args) {
		//Set<String> set = new HashSet<String>();
		HashSet<String> set = new HashSet<>();
		set.add("西瓜");
		set.add("苹果");
		set.add("香蕉");
		set.add("菠萝");
		set.add("菠萝");
		System.out.println(set.size());
		System.out.println(set.toString());
		for (String s : set) {
			System.out.println(s);
		}
		Iterator<String> it = set.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
	}

	public static void main(String[] args) {
		HashSet<Student> set = new HashSet<>();
		Student s2 = new Student("22222222", 2);
		Student s3 = new Student("3333333", 3);
		Student s4 = new Student("4444444", 4);
		Student s1 = new Student("1111", 1);
		set.add(s1);
		set.add(s2);
		set.add(s3);
		set.add(s4);
		set.add(new Student("1111", 1));
		System.out.println(set.size());
		System.out.println(set);
		boolean a = s1.equals(new Student("1111", 1));
		System.out.println(a);
	}

}

